#ifndef __XPC_AVAILABILITY_H__
#define __XPC_AVAILABILITY_H__

#include <Availability.h>

// Certain parts of the project use all the project's headers but have to build
// against Zin -- liblaunch_host being the example. So we need to define these.
#ifndef __MAC_10_9
#define __MAC_10_9 1090
#define __AVAILABILITY_INTERNAL__MAC_10_9 \
	__attribute__((availability(macosx, introduced=10.9)))
#endif // __MAC_10_9

#ifndef __AVAILABILITY_INTERNAL__MAC_10_2_DEP__MAC_10_9
#define __AVAILABILITY_INTERNAL__MAC_10_2_DEP__MAC_10_9
#endif // __AVAILABILITY_INTERNAL__MAC_10_2_DEP__MAC_10_9

#ifndef __AVAILABILITY_INTERNAL__MAC_10_3_DEP__MAC_10_9
#define __AVAILABILITY_INTERNAL__MAC_10_3_DEP__MAC_10_9
#endif // __AVAILABILITY_INTERNAL__MAC_10_3_DEP__MAC_10_9

#ifndef __AVAILABILITY_INTERNAL__MAC_10_4_DEP__MAC_10_9
#define __AVAILABILITY_INTERNAL__MAC_10_4_DEP__MAC_10_9
#endif // __AVAILABILITY_INTERNAL__MAC_10_4_DEP__MAC_10_9

#ifndef __AVAILABILITY_INTERNAL__MAC_10_5_DEP__MAC_10_9
#define __AVAILABILITY_INTERNAL__MAC_10_5_DEP__MAC_10_9
#endif // __AVAILABILITY_INTERNAL__MAC_10_5_DEP__MAC_10_9

#ifndef __AVAILABILITY_INTERNAL__MAC_10_6_DEP__MAC_10_9
#define __AVAILABILITY_INTERNAL__MAC_10_6_DEP__MAC_10_9
#endif // __AVAILABILITY_INTERNAL__MAC_10_6_DEP__MAC_10_9

#ifndef __AVAILABILITY_INTERNAL__MAC_10_7_DEP__MAC_10_9
#define __AVAILABILITY_INTERNAL__MAC_10_7_DEP__MAC_10_9
#endif // __AVAILABILITY_INTERNAL__MAC_10_7_DEP__MAC_10_9

#ifndef __AVAILABILITY_INTERNAL__MAC_10_8_DEP__MAC_10_9
#define __AVAILABILITY_INTERNAL__MAC_10_8_DEP__MAC_10_9
#endif // __AVAILABILITY_INTERNAL__MAC_10_8_DEP__MAC_10_9

#ifndef __MAC_10_10
#define __MAC_10_10 101000
#define __AVAILABILITY_INTERNAL__MAC_10_10 \
__attribute__((availability(macosx, introduced=10.10)))
#endif // __MAC_10_10

#ifndef __AVAILABILITY_INTERNAL__MAC_10_2_DEP__MAC_10_10
#define __AVAILABILITY_INTERNAL__MAC_10_2_DEP__MAC_10_10
#endif // __AVAILABILITY_INTERNAL__MAC_10_2_DEP__MAC_10_10

#ifndef __AVAILABILITY_INTERNAL__MAC_10_3_DEP__MAC_10_10
#define __AVAILABILITY_INTERNAL__MAC_10_3_DEP__MAC_10_10
#endif // __AVAILABILITY_INTERNAL__MAC_10_3_DEP__MAC_10_10

#ifndef __AVAILABILITY_INTERNAL__MAC_10_4_DEP__MAC_10_10
#define __AVAILABILITY_INTERNAL__MAC_10_4_DEP__MAC_10_10
#endif // __AVAILABILITY_INTERNAL__MAC_10_4_DEP__MAC_10_10

#ifndef __AVAILABILITY_INTERNAL__MAC_10_5_DEP__MAC_10_10
#define __AVAILABILITY_INTERNAL__MAC_10_5_DEP__MAC_10_10
#endif // __AVAILABILITY_INTERNAL__MAC_10_5_DEP__MAC_10_10

#ifndef __AVAILABILITY_INTERNAL__MAC_10_6_DEP__MAC_10_10
#define __AVAILABILITY_INTERNAL__MAC_10_6_DEP__MAC_10_10
#endif // __AVAILABILITY_INTERNAL__MAC_10_6_DEP__MAC_10_10

#ifndef __AVAILABILITY_INTERNAL__MAC_10_7_DEP__MAC_10_10
#define __AVAILABILITY_INTERNAL__MAC_10_7_DEP__MAC_10_10
#endif // __AVAILABILITY_INTERNAL__MAC_10_7_DEP__MAC_10_10

#ifndef __AVAILABILITY_INTERNAL__MAC_10_8_DEP__MAC_10_10
#define __AVAILABILITY_INTERNAL__MAC_10_8_DEP__MAC_10_10
#endif // __AVAILABILITY_INTERNAL__MAC_10_8_DEP__MAC_10_10

#ifndef __AVAILABILITY_INTERNAL__MAC_10_9_DEP__MAC_10_10
#define __AVAILABILITY_INTERNAL__MAC_10_9_DEP__MAC_10_10
#endif // __AVAILABILITY_INTERNAL__MAC_10_9_DEP__MAC_10_10

#ifndef __IPHONE_7_0
#define __IPHONE_7_0 70000
#define __AVAILABILITY_INTERNAL__IPHONE_7_0 \
	__attribute__((availability(ios, introduced=7.0)))
#endif // __IPHONE_7_0

#ifndef __AVAILABILITY_INTERNAL__MAC_10_4_DEP__MAC_10_9
#define __AVAILABILITY_INTERNAL__MAC_10_4_DEP__MAC_10_9
#endif // __AVAILABILITY_INTERNAL__MAC_10_4_DEP__MAC_10_9

#ifndef __AVAILABILITY_INTERNAL__MAC_10_5_DEP__MAC_10_9
#define __AVAILABILITY_INTERNAL__MAC_10_5_DEP__MAC_10_9
#endif // __AVAILABILITY_INTERNAL__MAC_10_5_DEP__MAC_10_9

#ifndef __AVAILABILITY_INTERNAL__MAC_10_6_DEP__MAC_10_9
#define __AVAILABILITY_INTERNAL__MAC_10_6_DEP__MAC_10_9
#endif // __AVAILABILITY_INTERNAL__MAC_10_6_DEP__MAC_10_9

#ifndef __AVAILABILITY_INTERNAL__MAC_10_7_DEP__MAC_10_9
#define __AVAILABILITY_INTERNAL__MAC_10_7_DEP__MAC_10_9
#endif // __AVAILABILITY_INTERNAL__MAC_10_7_DEP__MAC_10_9

#if __has_include(<simulator_host.h>)
#include <simulator_host.h>
#else // __has_include(<simulator_host.h>)
#ifndef IPHONE_SIMULATOR_HOST_MIN_VERSION_REQUIRED
#define IPHONE_SIMULATOR_HOST_MIN_VERSION_REQUIRED 999999
#endif // IPHONE_SIMULATOR_HOST_MIN_VERSION_REQUIRED
#endif // __has_include(<simulator_host.h>)

#define XPC_SIMULATOR_AVAILABILITY_STRING(version) \
	"Use of this interface on the iOS Simulator requires that its minimum supported OS be OS X v" version " or later."

#ifdef __XPC_BUILDING_XPC__
#define __XPC_IOS_SIMULATOR_AVAILABLE_STARTING__MAC_10_7
#define __XPC_IOS_SIMULATOR_AVAILABLE_STARTING__MAC_10_8
#define __XPC_IOS_SIMULATOR_AVAILABLE_STARTING__MAC_10_9
#else // __XPC_BUILDING_XPC__ || XPC_TARGET_IOS_SIMULATOR_HOST
#define __XPC_IOS_SIMULATOR_AVAILABLE_STARTING__MAC_10_7 \
	__attribute__((unavailable(XPC_SIMULATOR_AVAILABILITY_STRING("10.7"))))
#define __XPC_IOS_SIMULATOR_AVAILABLE_STARTING__MAC_10_8 \
	__attribute__((unavailable(XPC_SIMULATOR_AVAILABILITY_STRING("10.8"))))
#define __XPC_IOS_SIMULATOR_AVAILABLE_STARTING__MAC_10_9 \
	__attribute__((unavailable(XPC_SIMULATOR_AVAILABILITY_STRING("10.9"))))
#endif // __XPC_BUILDING_XPC__ || XPC_TARGET_IOS_SIMULATOR_HOST

#if IPHONE_SIMULATOR_HOST_MIN_VERSION_REQUIRED >= __MAC_10_6 && IPHONE_SIMULATOR_HOST_MIN_VERSION_REQUIRED < __MAC_10_7
// Nothing is available.
#elif IPHONE_SIMULATOR_HOST_MIN_VERSION_REQUIRED >= __MAC_10_7 && IPHONE_SIMULATOR_HOST_MIN_VERSION_REQUIRED < __MAC_10_8
// IPHONE_SIMULATOR_HOST_MIN_VERSION_REQUIRED >= __MAC_10_6 && IPHONE_SIMULATOR_HOST_MIN_VERSION_REQUIRED < __MAC_10_7
#undef __XPC_IOS_SIMULATOR_AVAILABLE_STARTING__MAC_10_7
#define __XPC_IOS_SIMULATOR_AVAILABLE_STARTING__MAC_10_7
#elif IPHONE_SIMULATOR_HOST_MIN_VERSION_REQUIRED >= __MAC_10_8 && IPHONE_SIMULATOR_HOST_MIN_VERSION_REQUIRED < __MAC_10_9
// IPHONE_SIMULATOR_HOST_MIN_VERSION_REQUIRED >= __MAC_10_6 && IPHONE_SIMULATOR_HOST_MIN_VERSION_REQUIRED < __MAC_10_7
#undef __XPC_IOS_SIMULATOR_AVAILABLE_STARTING__MAC_10_7
#define __XPC_IOS_SIMULATOR_AVAILABLE_STARTING__MAC_10_7
#undef __XPC_IOS_SIMULATOR_AVAILABLE_STARTING__MAC_10_8
#define __XPC_IOS_SIMULATOR_AVAILABLE_STARTING__MAC_10_8
#elif IPHONE_SIMULATOR_HOST_MIN_VERSION_REQUIRED >= __MAC_10_9
// IPHONE_SIMULATOR_HOST_MIN_VERSION_REQUIRED >= __MAC_10_6 && IPHONE_SIMULATOR_HOST_MIN_VERSION_REQUIRED < __MAC_10_7
#undef __XPC_IOS_SIMULATOR_AVAILABLE_STARTING__MAC_10_7
#define __XPC_IOS_SIMULATOR_AVAILABLE_STARTING__MAC_10_7
#undef __XPC_IOS_SIMULATOR_AVAILABLE_STARTING__MAC_10_8
#define __XPC_IOS_SIMULATOR_AVAILABLE_STARTING__MAC_10_8
#undef __XPC_IOS_SIMULATOR_AVAILABLE_STARTING__MAC_10_9
#define __XPC_IOS_SIMULATOR_AVAILABLE_STARTING__MAC_10_9
#else // IPHONE_SIMULATOR_HOST_MIN_VERSION_REQUIRED >= __MAC_10_6 && IPHONE_SIMULATOR_HOST_MIN_VERSION_REQUIRED < __MAC_10_7
#undef __XPC_IOS_SIMULATOR_AVAILABLE_STARTING__MAC_10_7
#define __XPC_IOS_SIMULATOR_AVAILABLE_STARTING__MAC_10_7
#undef __XPC_IOS_SIMULATOR_AVAILABLE_STARTING__MAC_10_8
#define __XPC_IOS_SIMULATOR_AVAILABLE_STARTING__MAC_10_8
#undef __XPC_IOS_SIMULATOR_AVAILABLE_STARTING__MAC_10_9
#define __XPC_IOS_SIMULATOR_AVAILABLE_STARTING__MAC_10_9
#endif // IPHONE_SIMULATOR_HOST_MIN_VERSION_REQUIRED >= __MAC_10_6 && IPHONE_SIMULATOR_HOST_MIN_VERSION_REQUIRED < __MAC_10_7

#if __has_attribute(unavailable)
#if TARGET_IPHONE_SIMULATOR && !__XPC_BUILDING_XPC__
#define __XPC_IOS_SIMULATOR_AVAILABLE_STARTING(builder) \
	__XPC_IOS_SIMULATOR_AVAILABLE_STARTING##builder
#else // TARGET_IPHONE_SIMULATOR && !__XPC_BUILDING_XPC__
#define __XPC_IOS_SIMULATOR_AVAILABLE_STARTING(builder)
#endif // TARGET_IPHONE_SIMULATOR && !__XPC_BUILDING_XPC__
#else // __has_attribute(unavailable)
#define __XPC_IOS_SIMULATOR_AVAILABLE_STARTING(builder)
#endif // __has_attribute(unavailable)

#endif // __XPC_AVAILABILITY_H__
